package com.hqyj.controller;

import com.hqyj.pojo.Role;
import com.hqyj.service.RoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * (Role)表控制层
 *
 * @author makejava
 * @since 2021-08-15 09:04:27
 */
@RestController
@RequestMapping("role")
public class RoleController {
    /**
     * 服务对象
     */
    @Resource
    private RoleService roleService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Role selectOne(Integer id) {
        return this.roleService.queryById(id);
    }


    @RequestMapping("queryRoleIds")
    @ResponseBody
    public Map<String,Object> queryRoleIds(){
        final HashMap<String, Object> map = new HashMap<>();
        final List<Role> roles = roleService.queryAllByLimit(0, 500);
        map.put("roles",roles);
        return map;
    }

}
